package com.li.onjava8.concurrent.cf.example.pizza;

import com.li.onjava8.concurrent.utils.Timer;

import java.util.stream.IntStream;

/**
 * 我们可以从尝试并行流方法开始：
 */
public class PizzaStreams {
    public static void main(String[] args) {
        Timer timer = new Timer();
        IntStream.range(0, 10)
                .mapToObj(Pizza::new)
                .parallel()
                .forEach(
                        pizza -> { while (!pizza.complete()) pizza.next(); }
                );
        System.out.println(timer.duration());

    }
}
